home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / madmotor.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  15KB  |  462 lines

  1. /***************************************************************************
  2.  
  3.   Mad Motor                                (c) 1989 Mitchell Corporation
  4.  
  5.   But it's really a Data East game..  Bad Dudes era graphics hardware with
  6.   Dark Seal era sound hardware.  Maybe a license for a specific territory?
  7.  
  8.   "This game is developed by Mitchell, but they entrusted PCB design and some
  9.   routines to Data East."
  10.  
  11.   Emulation by Bryan McPhail, mish@tendril.co.uk
  12.  
  13. ***************************************************************************/
  14.  
  15. #include "driver.h"
  16. #include "vidhrdw/generic.h"
  17. #include "cpu/h6280/h6280.h"
  18.  
  19. int  madmotor_vh_start(void);
  20. void madmotor_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  21.  
  22. READ_HANDLER( madmotor_pf1_rowscroll_r );
  23. WRITE_HANDLER( madmotor_pf1_rowscroll_w );
  24. READ_HANDLER( madmotor_pf1_data_r );
  25. READ_HANDLER( madmotor_pf2_data_r );
  26. READ_HANDLER( madmotor_pf3_data_r );
  27. WRITE_HANDLER( madmotor_pf1_data_w );
  28. WRITE_HANDLER( madmotor_pf2_data_w );
  29. WRITE_HANDLER( madmotor_pf3_data_w );
  30. WRITE_HANDLER( madmotor_pf1_control_w );
  31. WRITE_HANDLER( madmotor_pf2_control_w );
  32. WRITE_HANDLER( madmotor_pf3_control_w );
  33. extern unsigned char *madmotor_pf1_rowscroll;
  34. extern unsigned char *madmotor_pf1_data,*madmotor_pf2_data,*madmotor_pf3_data;
  35. static unsigned char *madmotor_ram;
  36.  
  37. /******************************************************************************/
  38.  
  39. static WRITE_HANDLER( madmotor_sound_w )
  40. {
  41.     soundlatch_w(0,data & 0xff);
  42.     cpu_cause_interrupt(1,H6280_INT_IRQ1);
  43. }
  44.  
  45. static READ_HANDLER( madmotor_control_r )
  46. {
  47.     switch (offset)
  48.     {
  49.         case 2: /* Player 1 & Player 2 joysticks & fire buttons */
  50.             return (readinputport(0) + (readinputport(1) << 8));
  51.  
  52.         case 4: /* Dip Switches */
  53.             return (readinputport(3) + (readinputport(4) << 8));
  54.  
  55.         case 6: /* Credits */
  56.             return readinputport(2);
  57.     }
  58.  
  59.     logerror("Unknown control read at %d\n",offset);
  60.     return 0xffff;
  61. }
  62.  
  63. /******************************************************************************/
  64.  
  65. static struct MemoryReadAddress madmotor_readmem[] =
  66. {
  67.     { 0x000000, 0x07ffff, MRA_ROM },
  68.     { 0x184000, 0x1847ff, madmotor_pf1_rowscroll_r },
  69.     { 0x188000, 0x189fff, madmotor_pf1_data_r },
  70.     { 0x198000, 0x1987ff, madmotor_pf2_data_r },
  71.     { 0x1a4000, 0x1a4fff, madmotor_pf3_data_r },
  72.     { 0x18c000, 0x18c001, MRA_NOP },
  73.     { 0x19c000, 0x19c001, MRA_NOP },
  74.     { 0x3e0000, 0x3e3fff, MRA_BANK1 },
  75.     { 0x3e8000, 0x3e87ff, MRA_BANK2 },
  76.     { 0x3f0000, 0x3f07ff, paletteram_word_r },
  77.     { 0x3f8000, 0x3f800f, madmotor_control_r },
  78.     { -1 }  /* end of table */
  79. };
  80.  
  81. static struct MemoryWriteAddress madmotor_writemem[] =
  82. {
  83.     { 0x000000, 0x07ffff, MWA_ROM },
  84.     { 0x18c000, 0x18c001, MWA_NOP },
  85.  
  86.     { 0x180000, 0x18001f, madmotor_pf1_control_w },
  87.     { 0x184000, 0x1847ff, madmotor_pf1_rowscroll_w, &madmotor_pf1_rowscroll },
  88.     { 0x188000, 0x189fff, madmotor_pf1_data_w, &madmotor_pf1_data },
  89.     { 0x190000, 0x19001f, madmotor_pf2_control_w },
  90.     { 0x198000, 0x1987ff, madmotor_pf2_data_w, &madmotor_pf2_data },
  91.     { 0x1a0000, 0x1a001f, madmotor_pf3_control_w },
  92.     { 0x1a4000, 0x1a4fff, madmotor_pf3_data_w, &madmotor_pf3_data },
  93.  
  94.     { 0x3e0000, 0x3e3fff, MWA_BANK1, &madmotor_ram },
  95.     { 0x3e8000, 0x3e87ff, MWA_BANK2, &spriteram },
  96.     { 0x3f0000, 0x3f07ff, paletteram_xxxxBBBBGGGGRRRR_word_w, &paletteram },
  97.     { 0x3fc004, 0x3fc005, madmotor_sound_w },
  98.     { -1 }  /* end of table */
  99. };
  100.  
  101. /******************************************************************************/
  102.  
  103. static WRITE_HANDLER( YM2151_w )
  104. {
  105.     switch (offset) {
  106.     case 0:
  107.         YM2151_register_port_0_w(0,data);
  108.         break;
  109.     case 1:
  110.         YM2151_data_port_0_w(0,data);
  111.         break;
  112.     }
  113. }
  114.  
  115. static WRITE_HANDLER( YM2203_w )
  116. {
  117.     switch (offset) {
  118.     case 0:
  119.         YM2203_control_port_0_w(0,data);
  120.         break;
  121.     case 1:
  122.         YM2203_write_port_0_w(0,data);
  123.         break;
  124.     }
  125. }
  126.  
  127. /* Physical memory map (21 bits) */
  128. static struct MemoryReadAddress sound_readmem[] =
  129. {
  130.     { 0x000000, 0x00ffff, MRA_ROM },
  131.     { 0x100000, 0x100001, YM2203_status_port_0_r },
  132.     { 0x110000, 0x110001, YM2151_status_port_0_r },
  133.     { 0x120000, 0x120001, OKIM6295_status_0_r },
  134.     { 0x130000, 0x130001, OKIM6295_status_1_r },
  135.     { 0x140000, 0x140001, soundlatch_r },
  136.     { 0x1f0000, 0x1f1fff, MRA_BANK8 },
  137.     { -1 }  /* end of table */
  138. };
  139.  
  140. static struct MemoryWriteAddress sound_writemem[] =
  141. {
  142.     { 0x000000, 0x00ffff, MWA_ROM },
  143.     { 0x100000, 0x100001, YM2203_w },
  144.     { 0x110000, 0x110001, YM2151_w },
  145.     { 0x120000, 0x120001, OKIM6295_data_0_w },
  146.     { 0x130000, 0x130001, OKIM6295_data_1_w },
  147.     { 0x1f0000, 0x1f1fff, MWA_BANK8 },
  148.     { 0x1fec00, 0x1fec01, H6280_timer_w },
  149.     { 0x1ff402, 0x1ff403, H6280_irq_status_w },
  150.     { -1 }  /* end of table */
  151. };
  152.  
  153. /******************************************************************************/
  154.  
  155. INPUT_PORTS_START( madmotor )
  156.     PORT_START    /* Player 1 controls */
  157.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  158.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  159.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  160.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  161.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  162.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  163.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )    /* button 3 - unused */
  164.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  165.  
  166.     PORT_START    /* Player 2 controls */
  167.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  168.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  169.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  170.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  171.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  172.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  173.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )    /* button 3 - unused */
  174.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  175.  
  176.     PORT_START    /* Credits */
  177.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  178.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  179.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  180.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
  181.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  182.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  183.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  184.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  185.  
  186.     PORT_START    /* Dip switch bank 1 */
  187.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
  188.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  189.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  190.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
  191.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
  192.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
  193.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
  194.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_5C ) )
  195.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_6C ) )
  196.     PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
  197.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  198.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  199.     PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
  200.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
  201.     PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
  202.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
  203.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
  204.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_6C ) )
  205.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )
  206.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  207.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  208.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  209.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  210.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  211.  
  212.     PORT_START    /* Dip switch bank 2 */
  213.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  214.     PORT_DIPSETTING(    0x00, "2" )
  215.     PORT_DIPSETTING(    0x03, "3" )
  216.     PORT_DIPSETTING(    0x02, "4" )
  217.     PORT_DIPSETTING(    0x01, "5" )
  218.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
  219.     PORT_DIPSETTING(    0x08, "Easy" )
  220.     PORT_DIPSETTING(    0x0c, "Normal" )
  221.     PORT_DIPSETTING(    0x04, "Hard" )
  222.     PORT_DIPSETTING(    0x00, "Hardest" )
  223.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
  224.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  225.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  226.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
  227.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  228.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  229.     PORT_DIPNAME( 0x40, 0x40, "Allow Continue" )
  230.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  231.     PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
  232.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  233.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  234.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  235. INPUT_PORTS_END
  236.  
  237. /******************************************************************************/
  238.  
  239. static struct GfxLayout charlayout =
  240. {
  241.     8,8,    /* 8*8 chars */
  242.     4096,
  243.     4,        /* 4 bits per pixel  */
  244.     { 0x18000*8, 0x8000*8, 0x10000*8, 0x00000*8 },
  245.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  246.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  247.     8*8    /* every char takes 8 consecutive bytes */
  248. };
  249.  
  250. static struct GfxLayout tilelayout =
  251. {
  252.     16,16,
  253.     2048,
  254.     4,
  255.     { 0x30000*8, 0x10000*8, 0x20000*8, 0x00000*8 },
  256.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  257.             0, 1, 2, 3, 4, 5, 6, 7 },
  258.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  259.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  260.     16*16
  261. };
  262.  
  263. static struct GfxLayout tilelayout2 =
  264. {
  265.     16,16,
  266.     4096,
  267.     4,
  268.     { 0x60000*8, 0x20000*8, 0x40000*8, 0x00000*8 },
  269.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  270.             0, 1, 2, 3, 4, 5, 6, 7 },
  271.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  272.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  273.     16*16
  274. };
  275.  
  276. static struct GfxLayout spritelayout =
  277. {
  278.     16,16,
  279.     4096*2,
  280.     4,
  281.     { 0xc0000*8, 0x80000*8, 0x40000*8, 0x00000*8 },
  282.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  283.             0, 1, 2, 3, 4, 5, 6, 7 },
  284.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  285.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  286.     16*16
  287. };
  288.  
  289. static struct GfxDecodeInfo gfxdecodeinfo[] =
  290. {
  291.     { REGION_GFX1, 0, &charlayout,     0, 16 },    /* Characters 8x8 */
  292.     { REGION_GFX2, 0, &tilelayout,   512, 16 },    /* Tiles 16x16 */
  293.     { REGION_GFX3, 0, &tilelayout2,  768, 16 },    /* Tiles 16x16 */
  294.     { REGION_GFX4, 0, &spritelayout, 256, 16 },    /* Sprites 16x16 */
  295.     { -1 } /* end of array */
  296. };
  297.  
  298. /******************************************************************************/
  299.  
  300. static struct OKIM6295interface okim6295_interface =
  301. {
  302.     2,              /* 2 chips */
  303.     { 7757, 15514 },/* ?? Frequency */
  304.     { REGION_SOUND1, REGION_SOUND2 },    /* memory regions */
  305.     { 50, 25 }        /* Note!  Keep chip 1 (voices) louder than chip 2 */
  306. };
  307.  
  308. static struct YM2203interface ym2203_interface =
  309. {
  310.     1,
  311.     21470000/6,    /* ?? Audio section crystal is 21.470 MHz */
  312.     { YM2203_VOL(40,40) },
  313.     { 0 },
  314.     { 0 },
  315.     { 0 },
  316.     { 0 }
  317. };
  318.  
  319. static void sound_irq(int state)
  320. {
  321.     cpu_set_irq_line(1,1,state); /* IRQ 2 */
  322. }
  323.  
  324. static struct YM2151interface ym2151_interface =
  325. {
  326.     1,
  327.     21470000/6, /* ?? Audio section crystal is 21.470 MHz */
  328.     { YM3012_VOL(45,MIXER_PAN_LEFT,45,MIXER_PAN_RIGHT) },
  329.     { sound_irq }
  330. };
  331.  
  332. static struct MachineDriver machine_driver_madmotor =
  333. {
  334.     /* basic machine hardware */
  335.     {
  336.          {
  337.             CPU_M68000, /* Custom chip 59 */
  338.             12000000, /* 24 MHz crystal */
  339.             madmotor_readmem,madmotor_writemem,0,0,
  340.             m68_level6_irq,1 /* VBL */
  341.         },
  342.         {
  343.             CPU_H6280 | CPU_AUDIO_CPU, /* Custom chip 45 */
  344.             8053000/2, /* Crystal near CPU is 8.053 MHz */
  345.             sound_readmem,sound_writemem,0,0,
  346.             ignore_interrupt,0
  347.         }
  348.     },
  349.     58, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration taken from Burger Time */
  350.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  351.     0,
  352.  
  353.     /* video hardware */
  354.     32*8, 32*8, { 0*8, 32*8-1, 1*8, 31*8-1 },
  355.  
  356.     gfxdecodeinfo,
  357.     1024, 1024,
  358.     0,
  359.  
  360.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK,
  361.     0,
  362.     madmotor_vh_start,
  363.     0,
  364.     madmotor_vh_screenrefresh,
  365.  
  366.     /* sound hardware */
  367.     0,0,0,0,
  368.       {
  369.         {
  370.             SOUND_YM2203,
  371.             &ym2203_interface
  372.         },
  373.         {
  374.             SOUND_YM2151,
  375.             &ym2151_interface
  376.         },
  377.         {
  378.             SOUND_OKIM6295,
  379.             &okim6295_interface
  380.         }
  381.     }
  382. };
  383.  
  384. /******************************************************************************/
  385.  
  386. ROM_START( madmotor )
  387.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  388.     ROM_LOAD_EVEN( "02", 0x00000, 0x20000, 0x50b554e0 )
  389.     ROM_LOAD_ODD ( "00", 0x00000, 0x20000, 0x2d6a1b3f )
  390.     ROM_LOAD_EVEN( "03", 0x40000, 0x20000, 0x442a0a52 )
  391.     ROM_LOAD_ODD ( "01", 0x40000, 0x20000, 0xe246876e )
  392.  
  393.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  394.     ROM_LOAD( "14",    0x00000, 0x10000, 0x1c28a7e5 )
  395.  
  396.     ROM_REGION( 0x020000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  397.     ROM_LOAD( "04",    0x000000, 0x10000, 0x833ca3ab )    /* chars */
  398.     ROM_LOAD( "05",    0x010000, 0x10000, 0xa691fbfe )
  399.  
  400.     ROM_REGION( 0x040000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  401.     ROM_LOAD( "10",    0x000000, 0x20000, 0x9dbf482b )    /* tiles */
  402.     ROM_LOAD( "11",    0x020000, 0x20000, 0x593c48a9 )
  403.  
  404.     ROM_REGION( 0x080000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  405.     ROM_LOAD( "06",    0x000000, 0x20000, 0x448850e5 )    /* tiles */
  406.     ROM_LOAD( "07",    0x020000, 0x20000, 0xede4d141 )
  407.     ROM_LOAD( "08",    0x040000, 0x20000, 0xc380e5e5 )
  408.     ROM_LOAD( "09",    0x060000, 0x20000, 0x1ee3326a )
  409.  
  410.     ROM_REGION( 0x100000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  411.     ROM_LOAD( "15",    0x000000, 0x20000, 0x90ae9f74 )    /* sprites */
  412.     ROM_LOAD( "16",    0x020000, 0x20000, 0xe96ac815 )
  413.     ROM_LOAD( "17",    0x040000, 0x20000, 0xabad9a1b )
  414.     ROM_LOAD( "18",    0x060000, 0x20000, 0x96d8d64b )
  415.     ROM_LOAD( "19",    0x080000, 0x20000, 0xcbd8c9b8 )
  416.     ROM_LOAD( "20",    0x0a0000, 0x20000, 0x47f706a8 )
  417.     ROM_LOAD( "21",    0x0c0000, 0x20000, 0x9c72d364 )
  418.     ROM_LOAD( "22",    0x0e0000, 0x20000, 0x1e78aa60 )
  419.  
  420.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  421.     ROM_LOAD( "12",    0x00000, 0x20000, 0xc202d200 )
  422.  
  423.     ROM_REGION( 0x20000, REGION_SOUND2 )    /* ADPCM samples */
  424.     ROM_LOAD( "13",    0x00000, 0x20000, 0xcc4d65e9 )
  425. ROM_END
  426.  
  427. /******************************************************************************/
  428.  
  429. static void madmotor_decrypt(void)
  430. {
  431.     unsigned char *RAM = memory_region(REGION_CPU1);
  432.     int i;
  433.  
  434.     for (i=0x00000; i<0x80000; i++) {
  435.         RAM[i]=(RAM[i] & 0xdb) | ((RAM[i] & 0x04) << 3) | ((RAM[i] & 0x20) >> 3);
  436.         RAM[i]=(RAM[i] & 0x7e) | ((RAM[i] & 0x01) << 7) | ((RAM[i] & 0x80) >> 7);
  437.     }
  438. }
  439.  
  440. static READ_HANDLER( cycle_r )
  441. {
  442.     int ret=READ_WORD(&madmotor_ram[0]);
  443.  
  444.     if (cpu_get_pc()==0x646e && (ret&0x8000)==0x8000) {
  445.         cpu_spinuntil_int();
  446.         return 0;
  447.     }
  448.  
  449.     return ret;
  450. }
  451.  
  452. static void init_madmotor(void)
  453. {
  454.     install_mem_read_handler(0, 0x3e0000, 0x3e0001, cycle_r);
  455.     madmotor_decrypt();
  456. }
  457.  
  458. /******************************************************************************/
  459.  
  460.  /* The title screen is undated, but it's (c) 1989 Data East at 0xefa0 */
  461. GAME( 1989, madmotor, 0, madmotor, madmotor, madmotor, ROT0, "Mitchell", "Mad Motor" )
  462.